package com.example.demo.repository;

import com.example.demo.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class StudentRepository {
    @SuppressWarnings("unused")
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @SuppressWarnings("unused")
    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;
    @Resource(name = "redisTemplate")
    ValueOperations<Object, Object> valueObj;
    @Resource(name = "redisTemplate")
    ValueOperations<String, String> valueStr;
    public void saveString(String key, String value) {valueStr.set(key, value);}
    public void saveStudent(Student stu) {valueObj.set(stu.getSno(),stu);}
    public void saveMultiStudents(Object key, List<Student> stus) {
        valueObj.set(key,stus);
    }
    public String getString(String key) {return valueStr.get(key);}
    public Object getObject(Object key) {return valueObj.get(key);}

}
